"""编写程序，读取并输出word文档中红色的文字。"""

from docx import Document
from docx.shared import RGBColor

redText = []
doc = Document('学习计划及到梦空间\心理学讲座感想.docx')
# 遍历所有段落文本
for p in doc.paragraphs:
    for r in p.runs:
        # 检查是否为红色字体
        if r.font.color.rgb == RGBColor(255, 0, 0):
            redText.append(r.text)

result = {'red.text': redText}

# 输出结果
for title in result.keys():
    print(title.center(30, '='))
    for text in result[title]:
        print(text)
